const componentFiles = require.context("./global", true, /\.vue$/); // 匹配 global 目录下所有 .vue 文件

export default function (app) {
  componentFiles.keys().forEach((key) => {
    const componentModule = componentFiles(key);
    const component = componentModule.default || componentModule;
    const componentName =
      component.name ||
      key
        .split("/")
        .pop()
        ?.replace(/\.vue$/, "");

    if (componentName) {
      app.component(componentName, component);
    }
  });
}
